package com.cskaoyan.controller;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.MarketSystem;
import com.cskaoyan.config.zhangshizhi.CountTime;
import com.cskaoyan.service.ConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author zhangsenqi
 * @Description
 * @Create 2022-06-25 17:49
 * @Version
 */
//响应结果都是JSON，Controller组件上我们都用@RestController注解
@RestController
@RequestMapping("admin/config")
public class ConfigController {

    @Autowired
    ConfigService configService;

    @CountTime
    @RequestMapping("mall")
    public BaseRespVo<MarketSystem> mall() {
        Map<String, String> map = configService.configMall();
        return BaseRespVo.ok(map);
    }

    @CountTime
    @PostMapping("mall")
    public BaseRespVo<MarketSystem> changeMall(@RequestBody Map<String, String> map) {
        configService.changeMall(map);
        return BaseRespVo.ok(map);
    }

    @CountTime
    @RequestMapping("express")
    public BaseRespVo<MarketSystem> express() {
        Map<String, String> map = configService.configExpress();
        return BaseRespVo.ok(map);
    }

    @CountTime
    @PostMapping("express")
    public BaseRespVo<MarketSystem> changeExpress(@RequestBody Map<String, String> map) {
        configService.changeExpress(map);
        return BaseRespVo.ok(map);
    }

    @CountTime
    @RequestMapping("order")
    public BaseRespVo<MarketSystem> order() {
        Map<String, String> map = configService.configOrder();
        return BaseRespVo.ok(map);
    }

    @CountTime
    @PostMapping("order")
    public BaseRespVo<MarketSystem> changeOrder(@RequestBody Map<String, String> map) {
        configService.changeOrder(map);
        return BaseRespVo.ok(map);
    }

    @CountTime
    @RequestMapping("wx")
    public BaseRespVo<MarketSystem> wx() {
        Map<String, String> map = configService.configWx();
        return BaseRespVo.ok(map);
    }

    @CountTime
    @PostMapping("wx")
    public BaseRespVo<MarketSystem> changeWx(@RequestBody Map<String, String> map) {
        configService.changeWx(map);
        return BaseRespVo.ok(map);
    }
}
